import Vue from 'vue'
import App from './App'

// i18N start 
import zhccore from '@/static/assets/csm/locales/zh.js'
import enccore from '@/static/assets/csm/locales/en.js'
import zhclogin from '@/static/assets/clogin/locales/zh.js'
import enclogin	 from '@/static/assets/clogin/locales/en.js'

import zhcsmwj from '@/static/assets/csmwj/locales/zh.js'
import encsmwj from '@/static/assets/csmwj/locales/en.js'

import VueI18n from 'vue-i18n' 
Vue.use(VueI18n)
const i18n = new VueI18n({
	locale: 'zh',
	messages: {
		'zh': Object.assign(zhccore, zhclogin,zhcsmwj),
		'en': Object.assign(enccore, enclogin,encsmwj),
	} 
})
Vue.prototype._i18n = i18n
// i18N end

// vuex
import store from './store'

// 引入全局uView
import uView from '@/uni_modules/uview-ui'

import mixin from './common/mixin'

Vue.prototype.$store = store

Vue.config.productionTip = false

App.mpType = 'app'
Vue.use(uView)

// #ifdef MP
// 引入uView对小程序分享的mixin封装
const mpShare = require('@/uni_modules/uview-ui/libs/mixin/mpShare.js')
Vue.mixin(mpShare)
// #endif

Vue.mixin(mixin)

const app = new Vue({
	//	i18n,	
	store,
	...App
})

// 引入请求封装
require('./util/request/index')(app)

// import $c from './static/assets/core/core.js'
import $c from './static/assets/csm/js/core.js'
Vue.use($c, app);

import $clogin from '@/static/assets/clogin/js/clogin.js'
Vue.use($clogin, app);

import $a from './static/assets/csmwj/app.js'
Vue.use($a, app);

//H5模式下，外部传入csmbaseurl，则为默认地址
if (window) {
	let csmbaseurl = null;
	let url = window.location.href;
	let theRequest = new Object();
	if (url.indexOf("?") != -1) {
		let str = url.substr(1);
		let strs = str.split("&");
		for (let i = 0; i < strs.length; i++) {
			theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
		}
	}
	if (theRequest['csmbaseurl'] != null && theRequest['csmbaseurl'] != '') {
		csmbaseurl = unescape(theRequest['csmbaseurl']);
	}
	uni.setStorageSync("csmbaseurl",csmbaseurl);
	console.log('setStorageSync - csmbaseurl = ',csmbaseurl);
}


app.$mount()
